<?php
class CPaystatu extends Zend_Db_Table
{
	protected $_name;
	protected $_primary;

	public function __construct()
	{
		$this->_name = R_PRE."paystatu";
		$this->_primary = "paystatu_id";
		parent::__construct();
		
	}

	public function add($data)
	{
		return $this->insert($data);		
	}
	
	public function getList($statu = '', $page = 1, $pageNum = 5)
	{
		$db = $this->getAdapter();
		$select = $db->select();
		$select->from($this->_name, array('*'))
			   ->limitPage($page, $pageNum);
		 
		if ($statu) {
			$select->where('statu = ?', $statu);
		}
		 
		$select->order('add_time desc');
		return $db->fetchAll($select);
	}
	
	public function getPageCount($statu = '', $pageNum = 5)
	{
		$db = $this->getAdapter();
		$select = $db->select();
		$select->from($this->_name, array('*'));
		
		if ($statu) {
			$select->where('statu = ?', $statu);
		}
		 
		$select->order('add_time desc');
		$result = $db->fetchAll($select);
		return ceil(count($result)/$pageNum);
	}
}